# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=jconvolver
pkgver=1.1.0
pkgrel=3
pkgdesc="A real-time convolution engine"
arch=('loong64' 'x86_64')
url="https://kokkinizita.linuxaudio.org/linuxaudio/"
license=('GPL2')
groups=('pro-audio')
depends=('glibc')
makedepends=('jack' 'libsndfile' 'zita-convolver')
source=("https://kokkinizita.linuxaudio.org/linuxaudio/downloads/${pkgname}-${pkgver}.tar.bz2"
        "https://kokkinizita.linuxaudio.org/linuxaudio/downloads/${pkgname}-reverbs.tar.bz2")
sha512sums=('fdac5fb43fce0db9012c734ace1c145429550ac30b3fef4b78ab01bf55cbe8fc08ea5319b0b023db30c04ee710b249c128b6b341f479b0c380a454c9b781c63b'
            'aa79dab5cb5326e6eddbf99a3cfae97cf5052db9d75c74346bf70f1b210db5576e31cff70c3d6dc8ff88b8eff74e4163a770fd537db978c2b955855f8b2dfc7b')
b2sums=('614c3b8f63294cbcfc56cae03a375f0d783364d05e0f68cc2547d015bb0b2318b3cfc5ee33214214e5ba0a6cca6ab540fb3e422e36275c1ea6daef18b18e1f98'
        '152c5cb3017fcc944e18b8d2aacf75cd90d1139ef6f29bc7d4970d273552bad22b542f1d74ffff55b033f80a9708129390b853083cf922820ea45e85255aabdc')

prepare() {
  cd "$pkgname-$pkgver"
  # remove optimization
  sed -e '/march=native/d' -i source/Makefile
  sed -e 's/-lclthreads //g' -i source/Makefile
}

build() {
  cd "$pkgname-$pkgver/source"
  make
}

package() {
  depends+=('libjack.so' 'libsndfile.so' 'libzita-convolver.so')
  cd "$pkgname-$pkgver/source"
  make DESTDIR="$pkgdir/" PREFIX=/usr install
  # docs
  install -vDm 644 ../{AUTHORS,README,README.CONFIG} \
    -t "${pkgdir}/usr/share/doc/${pkgname}/"
  # configs and examples
  cd ../config-files
  find . -type f \( -iname "*.conf" -or -iname "*.wav" \) -exec install -vDm 644 {} "${pkgdir}/usr/share/${pkgname}/"{} \;
  # reverbs
  cd "${srcdir}/reverbs"
  find . -type f \( -iname "*.conf" -or -iname "*.wav" \) -exec install -vDm 644 {} "${pkgdir}/usr/share/${pkgname}/examples/"{} \;
}
